#!/usr/bin/ruby -Ku
# -*- coding: utf-8 -*-
require 'test/unit'
require 'm3g'

class Test_Material < Test::Unit::TestCase
  def setup
  end

  def teadown
  end

  def test_defualt_variables
    mat = M3G::Material.new

    assert_equal false     , mat.vertex_color_tracking_enabled?
    assert_equal 0x00333333, mat.color[M3G::Material::AMBIENT]
    assert_equal 0xffcccccc, mat.color[M3G::Material::DIFFUSE]
    assert_equal 0x00000000, mat.color[M3G::Material::EMISSIVE]
    assert_equal 0x00000000, mat.color[M3G::Material::SPECULAR]
    assert_equal 0         , mat.shininess
  end

  def test_set_variables
    mat = M3G::Material.new

    mat.color[M3G::Material::AMBIENT]  = 0x12345678
    mat.color[M3G::Material::DIFFUSE]  = 0xff456789
    mat.color[M3G::Material::EMISSIVE] = 0x3456789a
    mat.color[M3G::Material::SPECULAR] = 0x456789ab
    mat.shininess                      = 1.0
    mat.vertex_color_tracking_enable   = true

    assert_equal true      , mat.vertex_color_tracking_enabled?
    assert_equal 0x00345678, mat.color[M3G::Material::AMBIENT]
    assert_equal 0xff456789, mat.color[M3G::Material::DIFFUSE]
    assert_equal 0x0056789a, mat.color[M3G::Material::EMISSIVE]
    assert_equal 0x006789ab, mat.color[M3G::Material::SPECULAR]
    assert_equal 1.0       , mat.shininess
  end

  def test_duplicate
    mat1 = M3G::Material.new

    mat1.color[M3G::Material::AMBIENT]  = 0x12345678
    mat1.color[M3G::Material::DIFFUSE]  = 0xff456789
    mat1.color[M3G::Material::EMISSIVE] = 0x3456789a
    mat1.color[M3G::Material::SPECULAR] = 0x456789ab
    mat1.shininess                      = 1.0
    mat1.vertex_color_tracking_enable   = true

    mat2 = mat1.duplicate

    assert_equal true      , mat2.vertex_color_tracking_enabled?
    assert_equal 0x00345678, mat2.color[M3G::Material::AMBIENT]
    assert_equal 0xff456789, mat2.color[M3G::Material::DIFFUSE]
    assert_equal 0x0056789a, mat2.color[M3G::Material::EMISSIVE]
    assert_equal 0x006789ab, mat2.color[M3G::Material::SPECULAR]
    assert_equal 1.0       , mat2.shininess

  end

end
